Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/messaging/src/commonTest/kotlin/org/meshtastic/feature/messaging/MentionQueryTest.kt f4506450168d047b225b277620bf0f1d5dcd13b5 (f4506450) Text, 2.31 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.messaging

Tff7b72import T7ee787androidx.compose.ui.text.TextRange
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals
Tff7b72import T7ee787kotlin.test.assertNull

Tff7b72class T56d364MentionQueryTest Tb4b4b4{

Tff7b72private Tff7b72fun Td2a8ffqueryTb4b4b4(Te6edf3textTb4b4b4: Tffa657StringTb4b4b4, Te6edf3cursorTb4b4b4: Tffa657Int Tff7b72= Te6edf3textTb4b4b4.Te6edf3lengthTb4b4b4) Tff7b72= Te6edf3currentMentionQueryTb4b4b4(Te6edf3textTb4b4b4, Te6edf3TextRangeTb4b4b4(Te6edf3cursorTb4b4b4)Tb4b4b4)

Tf0883e@Test
Tff7b72fun Td2a8ff`detects a query at the start`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Te6edf3MentionQueryTb4b4b4(Te6edf3start Tff7b72= T79c0ff0Tb4b4b4, Te6edf3end Tff7b72= T79c0ff3Tb4b4b4, Te6edf3query Tff7b72= Ta5d6ff"Ta5d6ffalTa5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ff@alTa5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`detects a query after whitespace`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Te6edf3MentionQueryTb4b4b4(Te6edf3start Tff7b72= T79c0ff3Tb4b4b4, Te6edf3end Tff7b72= T79c0ff7Tb4b4b4, Te6edf3query Tff7b72= Ta5d6ff"Ta5d6ffbobTa5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ffhi @bobTa5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`bare at-sign yields an empty query for showing all nodes`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Te6edf3MentionQueryTb4b4b4(Te6edf3start Tff7b72= T79c0ff0Tb4b4b4, Te6edf3end Tff7b72= T79c0ff1Tb4b4b4, Te6edf3query Tff7b72= Ta5d6ff"Ta5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ff@Ta5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`no at-sign means no query`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertNullTb4b4b4(Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ffhello thereTa5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`whitespace after the at-sign ends the query`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertNullTb4b4b4(Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ff@bob said hiTa5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`at-sign mid-word such as an email is not a mention`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertNullTb4b4b4(Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ffme@hostTa5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`a completed token followed by a space does not re-trigger`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertNullTb4b4b4(Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ff@!ffccee11 Ta5d6ff"Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`only the token left of the caret is considered`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// caret sits right after "@al"; the later "@bob" is ignored
Te6edf3assertEqualsTb4b4b4(Te6edf3MentionQueryTb4b4b4(Te6edf3start Tff7b72= T79c0ff0Tb4b4b4, Te6edf3end Tff7b72= T79c0ff3Tb4b4b4, Te6edf3query Tff7b72= Ta5d6ff"Ta5d6ffalTa5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3queryTb4b4b4(Ta5d6ff"Ta5d6ff@al @bobTa5d6ff"Tb4b4b4, Te6edf3cursor Tff7b72= T79c0ff3Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`a non-collapsed selection yields no query`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertNullTb4b4b4(Te6edf3currentMentionQueryTb4b4b4(Ta5d6ff"Ta5d6ff@bobTa5d6ff"Tb4b4b4, Te6edf3TextRangeTb4b4b4(T79c0ff1Tb4b4b4, T79c0ff4Tb4b4b4)Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s